package vn.gameloft.blockbreaker;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;

public class EndScreen extends ScreenAdapter {
    private static final String END_SCREEN_TITLE = "GOODBYE!";
    private BlockBreaker inGame;
    private BitmapFont text;

    public EndScreen(BlockBreaker sgm) {
        this.inGame = sgm;
        text = new BitmapFont();
        text.setColor(Color.BLUE);
        text.setUseIntegerPositions(true);
        Gdx.graphics.getGL20().glClearColor(0, 0, 0, 1);

    }

    @Override
    public void render(float delta) {
        if (Gdx.input.isKeyPressed(Input.Keys.SPACE)
                || Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
            Gdx.app.exit();
            return;
        }
        Gdx.graphics.getGL20().glClear(
                GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        inGame.batch.begin();
        text.draw(inGame.batch, END_SCREEN_TITLE, Gdx.graphics.getWidth() / 2,
                Gdx.graphics.getHeight() / 2);
        inGame.batch.end();
    }
}
